﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace PlutoStudio.Web
{
    public static class MefInitializer
    {
        public static void Initializer()
        {
            MefContainer.SetContainer(catalog =>
            {
                var context = HttpContext.Current;
                if (context==null)
                {

                }
                if (context.Items.Contains("MefContext"))
                {
                    return context.Items["MefContext"] as MefContext;
                }
                else
                {
                    var result = new MefContext(catalog);
                    if (context != null)
                    {
                        context.Items["MefContext"] = result;
                        context.DisposeOnPipelineCompleted(result);
                    }
                    return result;
                }
            });
        }
    }
}
